package com.qf.controller;

import com.qf.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/json")
public class JsonController {

    @RequestMapping("/test1")
    @ResponseBody
    public User test01() {
        System.out.println("test01");
        User user = new User(1, "张三", new Date());
        String[] hobby = {"football", "basketball"};
        user.setHobby(hobby);
        System.out.println(user);
        return user;
    }

    @RequestMapping("/test2")
    @ResponseBody
    public List<User> test02() {
        System.out.println("test02");
        User user = new User(1, "张三", new Date());
        String[] hobby = {"football", "basketball"};
        user.setHobby(hobby);
        User user1 = new User(2, "李四");
        System.out.println(user);
        System.out.println(user1);
        List<User> users = Arrays.asList(user, user1);
        return users;
    }
}
